<?
error_reporting(0);
	include("includes/db.php");
	include("includes/functions.php");
	
	if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){
		remove_product($_REQUEST['pid']);
	}
	else if($_REQUEST['command']=='clear'){
		unset($_SESSION['cart']);
	}
	else if($_REQUEST['command']=='update'){
		$max=count($_SESSION['cart']);
		for($i=0;$i<$max;$i++){
			$pid=$_SESSION['cart'][$i]['productid'];
			$q=intval($_REQUEST['product'.$pid]);
			if($q>0 && $q<=999){
				$_SESSION['cart'][$i]['qty']=$q;
			}
			else{
				$msg='Some proudcts not updated!, quantity must be a number between 1 and 999';
			}
		}
	}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<link rel="stylesheet" href="home_style.css" type="text/css" />
<link rel="stylesheet" href="cart.css" type="text/css" />
<script src="js/jquery-1.6.4.min.js"></script> 

<title>Loiter D85</title>

<script language="javascript">
	function del(pid){
		if(confirm('Do you really mean to delete this item')){
			document.form1.pid.value=pid;
			document.form1.command.value='delete';
			document.form1.submit();
		}
	}
	function clear_cart(){
		if(confirm('This will empty your shopping cart, continue?')){
			document.form1.command.value='clear';
			document.form1.submit();
		}
	}
	function update_cart(){
		document.form1.command.value='update';
		document.form1.submit();
	}


</script>

</head>

<body>
<form name="form1" method="post">
<input type="hidden" name="pid" />
<input type="hidden" name="command" />

<div class="background_1"> <!-- its height increase accourding to upper_main_body-->
<div class="background_2">
<div class="background_3"> 
    <div id="upper_main_body">
    	<div id="log_btn">
        	<p>Logi-In / Register</p>
        </div><!-- end of log_btn-->
        <div id="log_in">
        	<form>
            	<table cellspacing=" 8px">
                	<tbody>
                    	<tr>
            				<td><p>User Name:</p></td> 
                            <td><input type="text" id="log_styl" /></td>
                        </tr>
                        <tr>    
                			<td><p>Password:</p></td> 
                            <td><input type="password" id="log_styl" /></td>
                        </tr>
                        <tr>
                        	<td colspan="2"><input type="button" value="Sign in" style="float: right;" id="sign_btn"/></td>
                        </tr>
                        <tr>
                        	<td colspan="2"><p>Not registered yet? Please <span><a href="reg.html">Click Here to Register</a></span>.</p></td>
                        </tr>
                   </tbody>
               </table>
            </form>
        </div><!-- end of log_in-->
        <div id="search_1">
        	<input type="text"/>
            <a href="#"><div id="go_search">Search</div></a>
        </div><!-- end of search_1-->
        <div id="order_delivery">
        	<table><tr><td valign="top" class="order_0"><img src="home_images/phone.PNG" /></td><td><table><tr><td class="order_1" valign="top">Order Delivery</td></tr><tr><td class="order_2" valign="top">+880-1913566091</td></tr></table></td></tr></table>
        </div><!-- order_delivery-->
        
        <div id="loiter_logo"><img src="home_images/loiter_logo.PNG" /></div>
        
        <div id="shopping_cart">
        	<table><tr><td valign="top" class="cart_0"><img src="home_images/cart.PNG" /></td><td><table><tr><td class="cart_1" valign="top">Shopping Cart</td></tr><tr><td class="cart_2" valign="top">02 Items</td></tr></table></td></tr></table>
        </div><!-- shopping_cart-->
        
        <div id="upper_navigation">
        	<ul>
            	<a href="home_index.html"><li  class="active">Home</li></a>
                <a href="#"><li>About Us</li></a>
                <a href="#"><li>Products</li></a>
                <a href="#"><li>Contacts</li></a>
                <a href="#"><li>Ordering</li></a>
                <a href="#"><li>Reviews</li></a>
            </ul>
        </div><!-- upper_navigation -->
        
        <div id="slide_show">
        	
        </div><!-- end of slide_show-->
        
    </div><!-- end of upper_main_body-->
    
    
</div><!-- end of background_3-->
</div><!-- end of background_2-->
</div><!-- end of background_1-->

<div id="next_main_body">
    <div id="three_quality">
        <ul>
            <li>
                <div id="three_quality_1">
                	<div id="three_quality_1_tag"></div>
                    <p>Order your food online with us</p>
                </div><!-- three_quality_1 -->
            </li>
            <li>
                <div id="three_quality_2">
                	<div id="three_quality_2_tag"></div>
                    <p>We send, confirm & monitor your order</p>
                </div><!-- three_quality_1 -->
            </li>
            <li>
                <div id="three_quality_3">
                	<div id="three_quality_3_tag"></div>
                    <p>We prepare and deliver your food to you</p>
                </div><!-- three_quality_1 -->
            </li>
        </ul>
    </div><!-- three_quality -->
	
    <div id="cata_feathured">
    	<div id="catagories">
        	<div id="catagories_head"><p>Catergories</p></div>
            <ul class="nav_ul_1">
            	<li><a href="#">Rice Meal</a></li>
                <li><a href="#">Rice Meal</a></li>
                <li><a href="#">Rice Meal</a></li>
                <li><a href="#">Rice Meal</a></li>
                <li><a href="#">Rice a</a>
                	<ul class="nav_ul_2">
                        <li><a href="#">asdasd</a></li>
                        <li><a href="#">asdasd</a></li>
                    </ul>
                </li>
                <li><a href="#">Rice Meal</a></li>
                <li>Rice Meal</li>
            </ul>
            
            <div id="cart_side">
            	<img src="home_images/cart_1.PNG" />
                <table>
                	<tr>
                    	<td valign="top"><a href="#"><img src="home_images/x.PNG" border="none" /></a></td>
                        <td valign="top">1x2 Chicken Chilli Burger with French Fries</td>
                        <td valign="top" class="amount">= 400/-</td>
                    </tr>
                    <tr>
                    	<td valign="top"><a href="#"><img src="home_images/x.PNG" border="none" /></a></td>
                        <td valign="top">1x2 Chicken Chilli</td>
                        <td valign="top" class="amount">= 400/-</td>
                    </tr>
                    <tr>
                    	<td valign="top"><a href="#"><img src="home_images/x.PNG" border="none" /></a></td>
                        <td valign="top">1x2 Chicken Chilli Burger with French Fries</td>
                        <td valign="top" class="amount">= 4100/-</td>
                    </tr>
                    <tr>
                    	<td valign="top"><a href="#"><img src="home_images/x.PNG" border="none" /></a></td>
                        <td valign="top">1x2 Chicken Chilli Burger with French Fries</td>
                        <td valign="top" class="amount">= 1400/-</td>
                    </tr>
                </table>
                
                <div id="chart_divider"></div>
                <p>Total Price</p>
                <p><span>1300 Taka only</span></p>
                <div id="chart_check_out_outter"><a href="#"><div id="cart_check_out"><p>Check Out</p></div></a></div>
            </div> 
        </div><!-- end of catagories-->
        
        <div id="cart">
        	<div class="chkbtn"><input type="button" value="Continue Shopping" onclick="window.location='products.php'" /></div><!-- end of chkbtn-->
<body>
<form name="form1" method="post">
<input type="hidden" name="pid" />
<input type="hidden" name="command" />
	<div style="margin:0px auto; width:600px;" >
    <div style="padding-bottom:10px">
    	<h1 align="center">Your Shopping Cart</h1>
    <input type="button" value="Continue Shopping" onclick="window.location='products.php'" />
    </div>
    	<div style="color:#F00"><?=$msg?></div>
    	<table border="0" cellpadding="5px" cellspacing="1px" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; background-color:#E1E1E1" width="100%">
    	<?
			if(is_array($_SESSION['cart'])){
            	echo '<tr bgcolor="#FFFFFF" style="font-weight:bold"><td>Serial</td><td>Name</td><td>Price</td><td>Qty</td><td>Amount</td><td>Options</td></tr>';
				$max=count($_SESSION['cart']);
				for($i=0;$i<$max;$i++){
					$pid=$_SESSION['cart'][$i]['productid'];
					$q=$_SESSION['cart'][$i]['qty'];
					$pname=get_product_name($pid);
					if($q==0) continue;
			?>
            		<tr bgcolor="#FFFFFF"><td><?=$i+1?></td><td><?=$pname?></td>
                    <td>$ <?=get_price($pid)?></td>
                    <td><input type="text" name="product<?=$pid?>" value="<?=$q?>" maxlength="3" size="2" /></td>                    
                    <td>$ <?=get_price($pid)*$q?></td>
                    <td><a href="javascript:del(<?=$pid?>)">Remove</a></td></tr>
            <?					
				}
			?>
				<tr><td><b>Order Total: $<?=get_order_total()?></b></td><td colspan="5" align="right"><input type="button" value="Clear Cart" onclick="clear_cart()"><input type="button" value="Update Cart" onclick="update_cart()"><input type="button" value="Place Order" onclick="window.location='billing.php'"></td></tr>
			<?
            }
			else{
				echo "<tr bgColor='#FFFFFF'><td>There are no items in your shopping cart!</td>";
			}
		?>
        </table>
    </div>
</form>

                
                <div id="cart_itm">
                	<div id="des">
                    	<div id="des_cont">
                            <div id="itm_img"><img src="images/food_image_1.png" /> </div>
                            <div id="itm_det">
                                <h3>Rosted Beef Sub</h3>
                                <p>Etiam ultrices tellus ut libero tempor feugiat? Fusce eget libero diam.</p>
                            </div>
                        </div><!-- end of des_cont-->
                    </div><!-- end of des-->
                    
                    <div id="qty">
                    	<div id="qty_cont">
                        	<p id="qt_num">99</p> <hr />
                            <p id="p_style"><a href="">Update</a> &nbsp; &nbsp; <a href="">Remove</a></p>
                        </div>
                    </div>
                    
                    <div id="total">
                    	<div id="tot_cont">
                        	<p>Subtotal: <span>150</span> tk</p>
                        </div><!-- end of tot_cont-->
                    </div><!-- end of total-->
                </div><!-- end of cart_itm-->
            </div><!-- end of cart_cont-->
            
            <div id="cart_ttl">
            	<p id="ttl_p">Product Total: <span>300</span> tk</p>
                <div class="chkbtn"><p>CheckOut</p><img src="images/cart.png" /></div><!-- end of chkbtn-->
            </div><!-- end of cart_ttl-->
        </div><!-- end of cart-->
    </div><!-- end of cata_feathured-->
    
    
</div><!-- end of next_main_body -->
<div id="footer">
<div id="footer_shadow">
	<div id="footer_ul">
        <ul>
            <li><a href="#">About Us</a></li>
            <li><a href="#">Products</a></li>
            <li><a href="#">Contacts</a></li>
            <li><a href="#">Ordering</a></li>
            <li><a href="#">Reviews</a></li>
        </ul>
    </div>
    <p>Copyright © 2011,  webpers.com</p>
</div>
</div>

</body>
<script type="text/javascript">
i=0;
<!--$('#wrapper').mouseover(function(){i=i+1;alert(i);}).mouseout(function(){i=i-1;alert(i);})-->

</script>

<script>
        $("#log_btn").click(function(){

        $("#log_in").slideToggle("slow");
        return false;
        });
</script>
</html>
